<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Constructor</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.solrcollapsefunction.html">« SolrCollapseFunction</a></li>
      <li style="float: right;"><a href="solrcollapsefunction.getfield.html">SolrCollapseFunction::getField »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.solrcollapsefunction.html">SolrCollapseFunction</a></li>
    <li>Constructor</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="solrcollapsefunction.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SolrCollapseFunction::__construct</h1>
  <p class="verinfo">(PECL solr &gt;= 2.2.0)</p><p class="refpurpose"><span class="refname">SolrCollapseFunction::__construct</span> &mdash; <span class="dc-title">Constructor</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-solrcollapsefunction.construct-description">
  <h3 class="title">说明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SolrCollapseFunction::__construct</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$field</code><span class="initializer"> = ?</span></span>)</div>

  <p class="para rdfs-comment">
    Collapse Function constructor
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-solrcollapsefunction.construct-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">field</code></dt>

    <dd>

     <p class="para">
        The field name to collapse on.
     </p>
     <p class="para">
        In order to collapse a result. The field type must be a single valued String, Int or Float.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 examples" id="refsect1-solrcollapsefunction.construct-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-4681">
   <p><strong>示例 #1 <span class="function"><strong>SolrCollapseFunction::__construct()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">"bootstrap.php"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$options&nbsp;</span><span style="color: #007700">=&nbsp;array<br />(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'hostname'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOLR_SERVER_HOSTNAME</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'login'&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOLR_SERVER_USERNAME</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'password'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOLR_SERVER_PASSWORD</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'port'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOLR_SERVER_PORT</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'path'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">SOLR_SERVER_PATH<br /></span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$client&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SolrClient</span><span style="color: #007700">(</span><span style="color: #0000BB">$options</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SolrQuery</span><span style="color: #007700">(</span><span style="color: #DD0000">'*:*'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$func&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SolrCollapseFunction</span><span style="color: #007700">(</span><span style="color: #DD0000">'field_name'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$func</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setMax</span><span style="color: #007700">(</span><span style="color: #DD0000">'sum(cscore(),field(some_other_field))'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$func</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setSize</span><span style="color: #007700">(</span><span style="color: #0000BB">100</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$func</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setNullPolicy</span><span style="color: #007700">(</span><span style="color: #0000BB">SolrCollapseFunction</span><span style="color: #007700">::</span><span style="color: #0000BB">NULLPOLICY_EXPAND</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$query</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">collapse</span><span style="color: #007700">(</span><span style="color: #0000BB">$func</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$queryResponse&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$client</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$response&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$queryResponse</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getResponse</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$response</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </div>



 <div class="refsect1 seealso" id="refsect1-solrcollapsefunction.construct-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="methodname"><a href="solrquery.collapse.html" class="methodname" rel="rdfs-seeAlso">SolrQuery::collapse()</a> - Collapses the result set to a single document per group</span></li>
  </ul>
 </div>


</div></div></div></body></html>